//
//  WZHPopView.swift
//  ShiGuangJiaSwift
//
//  Created by 汪志浩 on 2022/7/23.
//

import Foundation
import UIKit

public class WZHPopView: UIView {
    public  weak var pop : OverlayController?
    public var isOnly = true
    /**配置尺寸,,子类可重写**/
    public func config_size() -> CGSize{
        return CGSize(width: 280, height: 410)
    }
    /**配置pop,子类可重写**/
    public func config_pop(pop:OverlayController){
        pop.presentationStyle = .transform(scale: 0.8)
        pop.maskStyle = .black(opacity: 0.8)
    }
    
    /**弹出**/
    public @objc func show() {
        
        let pop = OverlayController.init(view: self, size: config_size())
        pop.isOnly = isOnly
        config_pop(pop:pop)
        self.pop = pop
        k_currentWindow?.present(overlay: self.pop!)
    }
    
    /**弹出在对应的View上**/
    public func showin(view:UIView){
        view.layoutIfNeeded()
        let pop = OverlayController.init(view: self, size: config_size())
        pop.isOnly = isOnly
        config_pop(pop:pop)
        self.pop = pop
        view.present(overlay: self.pop!)
    }
    
    /**消失**/
    public func disMiss(complete:(()->())? = nil) {
        guard let pop = self.pop else {return}
        pop._baseView.dissmiss(overlay:pop,duration: 0.25,options: [.curveEaseOut],completion: complete)
//        self.pop?._dismiss(duration: 0.25, delay: 0, options:  [.curveEaseOut] ,completion: complete)
        
    }
    
   
}
